/** Lachlan Hewson-Doherty (h201384171)
 *  Diploma of Digital and Interactive Games
 *  lachlan_doherty@live.com.au
 *  2013
 */

package cabbage.database.operations;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import cabbage.database.utilities.DatabaseConnection;



public class CheckpointOps {
	
	

    
    private DatabaseConnection db;
   
    public void getCheckpointsByLevel(int levelZ) throws SQLException {
           
            db = new DatabaseConnection();
            Connection conn = db.getConnection();
           
           
            PreparedStatement ps = conn.prepareStatement("select c.checkpoint_id, c.checkpointtype_id, c.location_id, l.z from checkpoint c inner join location l on c.location_id=l.location_id where l.z=?");
            ps.setInt(1, levelZ);
            ResultSet rs = ps.executeQuery();
             while(rs.next()) {
                     System.out.println(rs.getInt("c.checkpoint_id"));
                     System.out.println(rs.getInt("c.checkpointtype_id"));
                     System.out.println(rs.getInt("c.location_id"));
                     System.out.println(rs.getInt("l.z"));
             }
             
             conn.close();
           
    }

}
